package cn.tedu._01mvcboot01.controller;

import cn.tedu._01mvcboot01.pojo.dto.BmiDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class BmiController {
    @PostMapping("/bmi")
    @ResponseBody
    public String bmi(@ModelAttribute BmiDTO bmiDTO) {
        double weight = bmiDTO.getWeight();
        double height = bmiDTO.getHeight();
        double v = weight / (height * height);
        if (v < 18.5) {
            return "太瘦了宝贝";
        }
        if (v < 24) {
            return "正常的呢宝贝";
        }
        if (v < 27) {
            return "微胖男孩吗，有点油腻了";
        }
        return "飞柱，滚啊";
    }
}
